<?php echo $header; ?>
<div id="content">
<div class="breadcrumb">
  <?php foreach ($breadcrumbs as $breadcrumb) { ?>
  <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
  <?php } ?>
</div>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
  <?php echo $shortcut_route;?> 
<div class="box">
  <div class="heading">
    <h1><img src="view/image/module.png" alt="" /> <?php echo $heading_title; ?></h1>
  </div>
  <div class="content">
     <?php echo $shortcut_module;?> 
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
    <table id="article_list_module" class="list">
        <thead>
          <tr>
            <td class="left"><?php echo $entry_layout; ?></td>
            <td class="left"><?php echo $entry_category; ?></td>
            <td class="left"><?php echo $entry_children_limit; ?></td>
            <td class="left"><?php echo $entry_article_limit; ?></td>
            <td class="left"><?php echo $entry_description_limit; ?></td>
            <td class="left"><?php echo $entry_position; ?></td>
            <td class="left"><?php echo $entry_status; ?></td>
            <td class="right"><?php echo $entry_sort_order; ?></td>            
            <td class="right">
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div></td>
          </tr>
        </thead>
      <?php $article_list_module_row = 0; ?>
        <?php foreach ($article_list_modules as $article_list_module) { ?>
        <tbody id="article_list_module-row<?php echo $article_list_module_row; ?>">
          <tr>
           <td class="left"><select name="article_list_module[<?php echo $article_list_module_row; ?>][layout_id]">
                <?php foreach ($layouts as $layout) { ?>
                <?php if ($layout['layout_id'] == $article_list_module['layout_id']) { ?>
                <option value="<?php echo $layout['layout_id']; ?>" selected="selected"><?php echo $layout['name']; ?></option>
                <?php } else { ?>
                <option value="<?php echo $layout['layout_id']; ?>"><?php echo $layout['name']; ?></option>
                <?php } ?>
                <?php } ?>
              </select></td>
              <td class="left">
              <select style="width:150px;" name="article_list_module[<?php echo $article_list_module_row; ?>][parent_id]">
                  
                  <?php foreach ($categories as $category) { ?>
                  <?php if ($category['article_category_id'] == $article_list_module['parent_id']) { ?>
                  <option value="<?php echo $category['article_category_id']; ?>" selected="selected"><?php echo $category['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $category['article_category_id']; ?>"><?php echo $category['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select>
              </td>
          <td class="left"><input type="text" name="article_list_module[<?php echo $article_list_module_row; ?>][children_limit]" value="<?php echo $article_list_module['children_limit']; ?>" size="3" /></td>
          <td class="left"><input type="text" name="article_list_module[<?php echo $article_list_module_row; ?>][limit]" value="<?php echo $article_list_module['limit']; ?>" size="3" /></td>
          <td class="left"><input type="text" name="article_list_module[<?php echo $article_list_module_row; ?>][description_limit]" value="<?php echo $article_list_module['description_limit']; ?>" size="3" /></td>
           
            <td class="left"><select name="article_list_module[<?php echo $article_list_module_row; ?>][position]">
                <?php if ($article_list_module['position'] == 'content_top') { ?>
                <option value="content_top" selected="selected"><?php echo $text_content_top; ?></option>
                <?php } else { ?>
                <option value="content_top"><?php echo $text_content_top; ?></option>
                <?php } ?>  
                <?php if ($article_list_module['position'] == 'content_bottom') { ?>
                <option value="content_bottom" selected="selected"><?php echo $text_content_bottom; ?></option>
                <?php } else { ?>
                <option value="content_bottom"><?php echo $text_content_bottom; ?></option>
                <?php } ?>     
               <!--  <?php if ($article_list_module['position'] == 'column_left') { ?>
                <option value="column_left" selected="selected"><?php echo $text_column_left; ?></option>
                <?php } else { ?>
                <option value="column_left"><?php echo $text_column_left; ?></option>
                <?php } ?>
                <?php if ($article_list_module['position'] == 'column_right') { ?>
                <option value="column_right" selected="selected"><?php echo $text_column_right; ?></option>
                <?php } else { ?>
                <option value="column_right"><?php echo $text_column_right; ?></option>
                <?php } ?> -->
              </select></td>
             <td class="left"><select name="article_list_module[<?php echo $article_list_module_row; ?>][status]">
                <?php if ($article_list_module['status']) { ?>
                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                <option value="0"><?php echo $text_disabled; ?></option>
                <?php } else { ?>
                <option value="1"><?php echo $text_enabled; ?></option>
                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                <?php } ?>
              </select></td>
            <td class="right"><input type="text" name="article_list_module[<?php echo $article_list_module_row; ?>][sort_order]" value="<?php echo $article_list_module['sort_order']; ?>" size="3" /></td>
            
            <td class="right"><a onclick="$('#article_list_module-row<?php echo $article_list_module_row; ?>').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>
		   </tr>
        </tbody>
        <?php $article_list_module_row++; ?>
        <?php } ?>
        <tfoot>
          <tr>
            <td colspan="8" class="left"><a href="http://www.opencart.com/index.php?route=extension/extension&filter_username=opencartplus.com" target="_blank" style="text-decoration:none; color:#FF0000;">View all free extension from OpencartPlus.com</a></td>
            <td class="right"><a onclick="addAjModule();" class="button"><span><?php echo $button_add_module; ?></span></a></td>
          </tr>
        </tfoot>
      </table>

	</form>
  </div>
</div>
<script type="text/javascript"><!--
var ajax_module_row = <?php echo $article_list_module_row; ?>;

function addAjModule() {	
	html  = '<tbody id="article_list_module-row' + ajax_module_row + '">';
	html += '  <tr>';
	html += '    <td class="left"><select name="article_list_module[' + ajax_module_row + '][layout_id]">';
	<?php foreach ($layouts as $layout) { ?>
	html += '      <option value="<?php echo $layout['layout_id']; ?>"><?php echo addslashes($layout['name']); ?></option>';
	<?php } ?>
	html += '    </select></td>';
    html +='<td class="left">';
    html +='          <select style="width:150px;" name="article_list_module[' + ajax_module_row + '][parent_id]">';
    html +='              <?php foreach ($categories as $category) { ?>';
    html +='              <option value="<?php echo $category['article_category_id']; ?>"><?php echo addslashes($category['name']); ?></option>';
    html +='              <?php } ?>';
    html +='            </select>';
    html +='          </td>';
    html += '    <td class="left"><input type="text" name="article_list_module[' + ajax_module_row + '][children_limit]" value="3" size="3" /></td>';
    html += '    <td class="left"><input type="text" name="article_list_module[' + ajax_module_row + '][limit]" value="3" size="3" /></td>';
    html += '    <td class="left"><input type="text" name="article_list_module[' + ajax_module_row + '][description_limit]" value="128" size="3" /></td>';
	html += '    <td class="left"><select name="article_list_module[' + ajax_module_row + '][position]">';
	html += '      <option value="content_top"><?php echo $text_content_top; ?></option>';
	html += '      <option value="content_bottom"><?php echo $text_content_bottom; ?></option>';
	html += '    </select></td>';
	html += '    <td class="left"><select name="article_list_module[' + ajax_module_row + '][status]">';
    html += '      <option value="1" selected="selected"><?php echo $text_enabled; ?></option>';
    html += '      <option value="0"><?php echo $text_disabled; ?></option>';
    html += '    </select></td>';
	html += '    <td class="right"><input type="text" name="article_list_module[' + ajax_module_row + '][sort_order]" value="99" size="3" /></td>';
	
	html += '    <td class="right"><a onclick="$(\'#article_list_module-row' + ajax_module_row + '\').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>';
	html += '  </tr>';
	html += '</tbody>';
	
	$('#article_list_module tfoot').before(html);
	
	ajax_module_row++;
}
//--></script>
<?php echo $footer; ?>